<?php
/**
 * @version		$Id: contact.php 10094 2008-03-02 04:35:10Z instance $
 * @package		Joomla
 * @subpackage	Test
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant to the
 * GNU General Public License, and as distributed it includes or is derivative
 * of works licensed under the GNU General Public License or other free or open
 * source software licenses. See COPYRIGHT.php for copyright notices and
 * details.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );


/**
 * @package		Joomla
 * @subpackage	Test
 */
class TableNode extends JTable
{
	/** @var int Primary key */
	var $nid 			=	0;
	/** @var int */
	var $vid			=	0;
	/** @var string */
	var $type			=	null;
	/** @var text */
	var $language		=	null;
	/** @var string */
	var $title			=	0;
	/** @INT user id */
	var $uid			=	0;
	/** @int. publish or not published*/
	var $status			=	0;
	/** @int. created date*/
	var $created		=	"";	
	/** @int. modified date*/
	var $changed		=	"";	
	
	/** @int. total comment*/
	var $comment		=	0;	
	/** @int. Promoted to front page*/
	var $promote		=	0;	

	// INT. default 0
	var $moderate		=	0;	
	/** @int. Sticky at top of lists*/
	var $sticky			=	0;	
	/** @int.*/
	var $tnid			=	0;	
	/** @int.*/
	var $translate		=	0;	
	
	/**
	* @param database A database connector object
	*/
	function TableNode(&$db)
	{
		$db2	=	$this->getDBO();
		parent::__construct( '#__node', 'nid', $db2 );
	}
	function getDBO()
	{
		require(JPATH_COMPONENT_ADMINISTRATOR.DS.'cms'.DS.'joomlapost'.DS.'cms_config.php');		
		$option_ 	= array(); //prevent problems 
		$option_['driver']   = $d_w_driver;       	// Database driver name
		$option_['host']     = $d_w_host;    		// Database host name
		$option_['user']     = $d_w_user;  	    	// User for database authentication
		$option_['password'] = $d_w_password;  		// Password for database authentication
		$option_['database'] = $d_w_database;  	  	// Database name
		$option_['prefix']   = $d_w_prefix;          // Database prefix (may be empty)
		if (empty($option_['user']) || empty($option_['password']) || empty($option_['database']) || empty($option_['driver']) || empty($option_['host']))
		{
			$config	=	JFactory::getConfig();
			
			$option_['driver']   = $config->getValue('dbtype');       	// Database driver name
			$option_['host']     = $config->getValue('host');    		// Database host name
			$option_['user']     = $config->getValue('user');  	    	// User for database authentication
			$option_['password'] = $config->getValue('password');  		// Password for database authentication
			$option_['database'] = $config->getValue('db');  	  	// Database name
		}
		$db_	= &JDatabase::getInstance( $option_ );
		if (!empty($db_->message)) {
				$this->msg = JText::sprintf($db_->message);
				return false;
			}	
		$this->_dbo=$db_;
		return $this->_dbo;
	}
}
